package com.cw.action.panel;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Icon;
import javax.swing.JCheckBox;

import com.cw.maintenance.AddDataDialog;

public class CheckBoxAction extends AbstractAction {
	int row;
	AddDataDialog target;

	public CheckBoxAction() {
		super();
	}

	public CheckBoxAction(String name) {
		super(name);
	}

	public CheckBoxAction(String name, Icon icon, int row, AddDataDialog tar) {
		super(name, icon);
		this.target = tar;
		this.row = row;
	}

	/**
	 * Invoked when an action occurs.
	 * 
	 * @param e
	 *            ActionEvent
	 * @todo Implement this java.awt.event.ActionListener method
	 */
	public void actionPerformed(ActionEvent e) {
		int col = target.getChkPanel().getCol();
		target.getChkPanel().txtqh[row].setEnabled(((JCheckBox) e
				.getSource()).isSelected());
		target.getChkPanel().txtkjsj[row].setEnabled(((JCheckBox) e
				.getSource()).isSelected());
		for (int i = 0; i < col; i++) {
			target.getChkPanel().cpball[row * col + i].setEnabled(((JCheckBox) e
					.getSource()).isSelected());
		}
	}
}
